#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    int n = 0;
    cin >> n;
    vector<int> arr(n + 1);
    for(int i = 1; i <= n; ++i)
    {
        cin >> arr[i];
    }
    vector<int> g(n + 1), f(n + 1); // 选和不选
    for(int i = 1; i <= n; ++i)
    {
        f[i] = g[i - 1] + arr[i];
        g[i] = max(f[i - 1], g[i - 1]);
    }
 
    cout << max(g[n], f[n]) << endl;
    return 0;
}